//javascript is a programming language

//variable

var count = 0;//loosely typed language

//what are the values we can save in variables

// Datatypes

//Number

//String
//Boolean
//Array
//Date
//Regexp

//null
//undefined


//Objects // function

//Number

var total = 10;
total = 10.0;
total = 10.56;

//

var counter = 10;// 10

counter = counter + 1; //11
counter += 1; //12
counter ++; // 13
++counter; //14

counter + 5;//19 -- 14

counter += 10;//24

// -
counter = counter - 10;//14
counter -= 1;//13

//* -- multiplication
// / -- division

counter = counter * 3;//39
counter /= 3;//counter = counter/3 -- 13

//string

var fullName = "john " + ' batson';//john  batson // concatenation

// datatypes there

counter = counter + 50; //63
counter = counter + '3';//'633'
// '63' + '3' -- '633'
//auto conversion or typecasting
counter = counter + 66; //'63366'
//counter -- string -- '63366'

//documentation -- javascript -- MDN (Mozilla Developer Network)
//Brendon Eich -- founder of javascript

//BOOLEAN -- true or false;
 var isVisible = true;
isVisible = false;

// Arrays
// Collection of items

var numbers = [1,2,3,4];
var mixedCollection = [false,'sentence',10, true,'A'];

//adding a number to the end of the array
numbers.push(5);// [1,2,3,4,5]
numbers.length;//5

//get the last item from the array and delete it from the array
var lastNumber = numbers.pop();// [1,2,3,4]

//removing the first item from the array
var firstNumber = numbers.shift();[2,3,4]

//how to add an item to the beginning of the array

numbers.unshift(10);//[10,2,3,4]

//loop

//number is even
// number is odd

for(var i = 0; i < numbers.length; i++){
    if(numbers[i]%2 === 0){
        console.log('number '+ numbers[i] + ' is even number')
    }else if(numbers[i] === 3){
        console.log('number is three');
    }
    else{
        console.log('number '+ numbers[i] + ' is odd number')
    }
}

//if, else if ,else

var mixedCollection = [0,10,20,true,false,0,'0','false','200', 2000];

//0
//mixedCollection[0];//

//= assignment
// == comparision by automatic type conversion
// === strict comparision with out type conversion
for(var j = 0; j < mixedCollection.length; j++){
    if(mixedCollection[j] === 0){ //true
        console.log('number at '+ j +' th position is zero')
    }
}
//0,5
//0,4,5,6 //
// false == 0 //true
// false == false
//'0' == 0
// '0' == '0'
// 'false' == '0'//
//automatic type conversion -- from one datatype to another -- implicit data conversion

//Number
//String
//Boolean
//Array

//Date -- Regexp

//null
//undefined

var final;

//undefined
console.log(final);// undefined
final = 10;
final = null;//novalue

//typeof

var counter  = 100;

console.log(typeof  counter);//"Number"
//typeof undefined --undefined
// typeof null -- object

//Number, String, Boolean, Array, Date, Regexp
// null and undefined

// Objects

//collection of key and value pairs

var person = {
    name: "john",
    'age' : 28,
    'location': "new york",
    'primary skill': 'javascript',
    'dateOfBirth': ''//convention
}

// person

//three types of operations
var keyName = 'location'
//get a value of a key
person.name ;//john
person['primary skill'] //javascript
person['name'];//john
person[keyName];//person['location']// new york
person['keyName'];//undefined



//set a value to a key
person.age = 29;
person['age'] = 29;
person.eyeColor = 'blue';
//person.eyEColor// undefined


person.eyeColor//blue
//delete a key from an object

delete person.dateOfBirth
delete person['dateOfBirth']





